package edu.online.dal;

import edu.online.entity.LeaveLessonEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface LeaveLessonEntityMapper {
    @Delete({
        "delete from leavelesson",
        "where LeaveLessonID = #{leavelessonid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String leavelessonid);

    @Insert({
        "insert into leavelesson (LeaveLessonID, LessonID, ",
        "StudentId, AdminUserId, ",
        "RequestTime, ConfirmTime)",
        "values (#{leavelessonid,jdbcType=CHAR}, #{lessonid,jdbcType=CHAR}, ",
        "#{studentid,jdbcType=CHAR}, #{adminuserid,jdbcType=CHAR}, ",
        "#{requesttime,jdbcType=TIMESTAMP}, #{confirmtime,jdbcType=TIMESTAMP})"
    })
    int insert(LeaveLessonEntity record);

    @InsertProvider(type=LeaveLessonEntitySqlProvider.class, method="insertSelective")
    int insertSelective(LeaveLessonEntity record);

    @Select({
        "select",
        "LeaveLessonID, LessonID, StudentId, AdminUserId, RequestTime, ConfirmTime",
        "from leavelesson",
        "where LeaveLessonID = #{leavelessonid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="LeaveLessonID", property="leavelessonid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="LessonID", property="lessonid", jdbcType=JdbcType.CHAR),
        @Result(column="StudentId", property="studentid", jdbcType=JdbcType.CHAR),
        @Result(column="AdminUserId", property="adminuserid", jdbcType=JdbcType.CHAR),
        @Result(column="RequestTime", property="requesttime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="ConfirmTime", property="confirmtime", jdbcType=JdbcType.TIMESTAMP)
    })
    LeaveLessonEntity selectByPrimaryKey(String leavelessonid);

    @UpdateProvider(type=LeaveLessonEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(LeaveLessonEntity record);

    @Update({
        "update leavelesson",
        "set LessonID = #{lessonid,jdbcType=CHAR},",
          "StudentId = #{studentid,jdbcType=CHAR},",
          "AdminUserId = #{adminuserid,jdbcType=CHAR},",
          "RequestTime = #{requesttime,jdbcType=TIMESTAMP},",
          "ConfirmTime = #{confirmtime,jdbcType=TIMESTAMP}",
        "where LeaveLessonID = #{leavelessonid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(LeaveLessonEntity record);
}